
#ifndef _TTG_LOGGER_LOGGERSETTINGS_
#define _TTG_LOGGER_LOGGERSETTINGS_
#include "Common/Definitions.h"

#include "Runtime.Low/Services/Service.h"
#include "Runtime.Low/Services/ServiceSettings.h"

namespace ttg
{
	namespace services
	{
		//Settings for Logger service.
		class LoggerSettings :public ttg_internal::services::ServiceSettings
		{
			public:
				//Defines filter for messages.
				enum MessageFilter
				{
					Errors,					//only errors.
					UserMessages,			//user messages (that can be made by calling Logger::addMessage).
					ttgLibMessages,			//Internal messages for ttgLib events.
					All						//all types of messages.
				};
				//Defines action, that should be performed.
				enum OnMessageAction
				{
					ShowMessageBox,			//Shows modal message box.
					PrintToConsole,			//Prints to console.
					PrintToFile,			//Prints to log file.
					Ignore					//Ignores this messages.
				};
			private:
				std::string logfile;
				OnMessageAction actions[3];
				//Returns name for required log-file (or NULL).
				inline const char *getLogFile()
				{ return logfile.empty() ? NULL : logfile.c_str(); }
				//Returns action for required filter.
				//Note: Filter "all" is not supported by this method.
				inline OnMessageAction getAction(MessageFilter filter)
				{ return filter == All ? Ignore : actions[filter]; }
			public:
				//Creates default settings:
				// - User messages will be printed to console or log-file.
				// - Errors will be shown via MessageBox.
				// - ttgLib messages will be ignored.
				LoggerSettings();
				//Enables logger service (console will be used instead of log-file).
				void enable();
				//Enables logger service (using requred log-file).
				void enable(const char *filename);
				//Dsables log-service.
				void disable();
				//Sets new filter for messages. Rewrites previous overlapped filters.
				//Example: set(All, PrintToFile);
				//		   set(Errors, ShowMessageBox);
				void set(MessageFilter filter, OnMessageAction action);
				//Returns string, that represents settings for the target service.
				virtual std::string serialize();
				//Deserializes settings. In case of error  returns default settings.
				static LoggerSettings deSerialize(const char *value);
			friend class Logger;
		};
	}
}

#endif
